package com.enba.boot.generator.config;

import com.enba.boot.core.base.ShowBootInfo;
import com.enba.boot.generator.generator.AutoGeneratorHelper;
import com.enba.boot.generator.properties.GeneratorProperties;
import javax.annotation.PostConstruct;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ConditionalOnProperty(prefix = "generator", name = "enabled", havingValue = "true")
@EnableConfigurationProperties(GeneratorProperties.class)
@Configuration
public class GeneratorAutoConfiguration implements ShowBootInfo {

  @Bean
  public AutoGeneratorHelper getAutoGeneratorHelper(GeneratorProperties generatorProperties) {
    return new AutoGeneratorHelper(generatorProperties);
  }

  @PostConstruct
  @Override
  public void showBootInfo() {
    ShowBootInfo.moduleMap.put("enba-boot-starter-generator", "enba-boot-starter-generator模块集成成功");
  }
}
